<!DOCTYPE html>
<html lang="en">
	<head>
		<link rel="icon" type="image/png" href="img/logo/favicon128.png">
		<meta http-equiv=Content-Type content="text/html;charset=utf-8">
		<!-- 要用到的CSS -->
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link href="css/bootstrap.css" rel="stylesheet">
		<link href="css/prettify.css" rel="stylesheet">

		<!-- 我的自定义CSS -->
		<link href="css/cdoj.css" rel="stylesheet">

		<!-- 要用到的JS -->
		<script src="js/jquery.min.js"></script>
		<script src="js/bootstrap.js"></script>
		<script src="js/prettify.js"></script>
		<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
		<!-- 如果需要开启内网模式的话请解压MathJax.zip到plugin目录下然后将上面替换成这个
		<script type="text/javascript" src="plugin/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
		-->
		<script src="plugin/ckeditor/ckeditor.js"></script>
		<script src="plugin/edit_area/edit_area_full.js"></script>

		<script src="js/cdoj.js"></script>

		<!-- 网站标题，暂时先这样 -->
		<title>${position} - UESTC Online Judge</title>

	</head>

	<body>
		<!-- 
		Navbar 
		@TODO:
		决定导航上的项目有哪些
		分隔符的颜色需要微调
		Navbar都要用
		-->
		<div class="navbar navbar-fixed-top">
			<div class="navbar-inner">
				<div class="container">
					<!-- 留白。。。 -->
					<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
						<span class="icon-bar"></span>
					</a><!-- 留白。。。 -->

					<!-- 导航部分 -->
					<ul class="nav">
						<!-- 当前页面class为active -->
						<li class="active">
						<a href="./index.html#">CDOJ</a>
						</li>
						<li class="divider-vertical"></li>

						<li>
						<a href="./problem.html">Problems</a>
						</li>
						<li class="divider-vertical"></li>

						<li>
						<a href="./contest.html">Contests</a>
						</li>
						<li class="divider-vertical"></li>

						<li>
						<a href="./statu.html">Status</a>
						</li>
						<li class="divider-vertical"></li>

						<li>
						<a href="./ranklist.html">Ranklist</a>
						</li>
						<li class="divider-vertical"></li>

						<li class="dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">Links<b class="caret"></b></a>
						<ul class="dropdown-menu">
							<!-- 固定链接 -->
							<li><a href="#">BBS</a></li>
							<li><a href="#">Wiki</a></li>
							<li><a href="http://www.mzry1992.com/blog/">mzry1992.com</a></li>

							<!-- Click这里就交给何老师了 -->
							<li class="divider"></li>
							<li class="nav-header">Click</li>
							<li><a href="#">F.A.Q</a></li>
							<li><a href="#">Download</a></li>
							<li><a href="#">Step-by-Step</a></li>
							<li><a href="#">Team Honors</a></li>

						</ul>
						</li>
						<li class="divider-vertical"></li>

					</ul><!-- 导航部分 -->

					<!-- 快速搜索框 -->
					<form class="navbar-search pull-right" action="">
						<input type="text" class="search-query span2" placeholder="Search">
					</form>

					<!-- 用户信息菜单，自行取用 -->
					<!-- 
					用户信息菜单，登陆后
					-->
					<ul class="nav pull-right">
						<li class="dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">
							<i class="icon-user"></i>
							${user.name}
							<b class="caret"></b>
						</a>
						<ul class="dropdown-menu">
							<!-- 用户中心的入口 -->
							<li>
							<a href="./usercenter.html">
								<i class="icon-home"></i>
								User center
							</a>
							</li>

							<!-- 未读消息 -->
							<li>
							<a href="./message.html">
								<i class="icon-envelope"></i>
								Message
								<span class="badge badge-success">2</span>
							</a>
							</li>

							<!-- 收藏夹 -->
							<li>
							<a href="./bookmark.html">
								<i class="icon-folder-open"></i>
								Bookmark
							</a>
							</li>

							<!-- 登出 -->
							<li>
							<a href="./logout.html">
								<i class="icon-off"></i>
								Logout
							</a>
							</li>
						</ul>
						</li>
					</ul><!-- 用户相关的菜单 -->

					<!-- 
					用户信息菜单，没有登录的时候
					-->
					<ul class="nav pull-right">
						<li class="dropdown">
						<a href="#" class="dropdown-toggle" data-toggle="dropdown">
							<i class="icon-pencil"></i>
							Login
							<b class="caret"></b>
						</a>
						<ul class="dropdown-menu">
							<!-- 登陆按钮 -->
							<li>
							<a href="./login.html">
								<i class="icon-ok-circle"></i>
								Login
							</a>
							</li>

							<!-- 注册按钮 -->
							<li>
							<a href="./register.html">
								<i class="icon-plus-sign"></i>
								Register
							</a>
							</li>

						</ul>
						</li>
					</ul><!-- 用户相关的菜单 -->

				</div>
			</div>
		</div><!-- navbar -->

		<!-- 正文 -->
		<div id="wrap">
			<div class="container">
				<!-- 这一部分保留给NOTICE信息 -->
				<div class="row">
					<div class="span12">
						<div class="alert alert-block">
							<div class="row">
								<div class="span1">
									<h4 class="alert-heading">Notice</h4>
								</div>
								<div class="span10">
									<marquee class="notice" onmouseover="javascript:this.stop();" onmouseout="javascript:this.start()">
									<!-- 新消息 -->
									<span class="label label-important">new</span>
									<a href="#">趣味赛第五场（正式赛）比赛推迟(2012-12-15 13:06:00)</a>
									&nbsp;&nbsp;&nbsp;&nbsp;

									<!-- 旧消息 -->
									<a href="#">趣味赛正式赛时间和机房开放的通知(2012-09-14 12:30:42)</a>
									&nbsp;&nbsp;&nbsp;&nbsp;

									<a href="#">趣味赛正式赛时间和机房开放的通知(2012-09-14 12:30:42)</a>
									&nbsp;&nbsp;&nbsp;&nbsp;

									<a href="#">趣味赛正式赛时间和机房开放的通知(2012-09-14 12:30:42)</a>
									&nbsp;&nbsp;&nbsp;&nbsp;

									</marquee>
								</div>
							</div>
						</div>
					</div>
				</div><!-- NOTICE -->



				<div class="problem">
					<div class="row">
						<!-- 题目标题 -->
						<div class="span12">
							<h2>Problem 9999. One million ways to make love</h2>
						</div>

						<!-- 导航链接 -->
						<div class="span12">
							<ul class="nav nav-pills">
								<li class="active">
								<a href="#">Problem</a>
								</li>
								<li><a href="./problem_single_submit.html">Submit</a></li>
								<li><a href="./problem_single_status.html">Status</a></li>
								<li><a href="./problem_single_discuss.html">Discuss</a></li>
							</ul>

						</div>

	


<!-- 题目信息 -->
<div class="span12">
	<dl class="dl-horizontal">
		<dt>Time limit</dt>
		<dd><span>2 / 1 second (Java / others)</span></dd>

		<dt>Memory limit</dt>
		<dd><span>128 / 64 megabytes (Java / others)</span></dd>

		<dt>Total accepted</dt>
		<dd><span>100</span></dd>

		<dt>Total submissions</dt>
		<dd><span>1000</span></dd>

	</dl>
</div>

<!-- 描述 -->
<div class="span12">

	<p>
	\begin{align}
	\dot{x} & = \sigma(y-x) \\
	\dot{y} & = \rho x - y - xz \\
	\dot{z} & = -\beta z + xy
	\end{align}
	</p>

	<p>\[
	\left( \sum_{k=1}^n a_k b_k \right)^{\!\!2} \leq
	\left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)
	\]</p>

	<p>\[
	\mathbf{V}_1 \times \mathbf{V}_2 =
	\begin{vmatrix}
	\mathbf{i} & \mathbf{j} & \mathbf{k} \\
	\frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
	\frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \\
	\end{vmatrix}
	\]</p>

	<p>\[P(E) = {n \choose k} p^k (1-p)^{ n-k} \]</p>

	<p>\[
	\frac{1}{(\sqrt{\phi \sqrt{5}}-\phi) e^{\frac25 \pi}} =
	1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}
	{1+\frac{e^{-8\pi}} {1+\ldots} } } }
	\]</p>

	<p>\[
	1 +  \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots =
	\prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},
	\quad\quad \text{for $|q|<1$}.
	\]</p>

	<p>
	\begin{align}
	\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
	\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
	\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
	\nabla \cdot \vec{\mathbf{B}} & = 0
	\end{align}
	</p>

	<p>Finally, while display equations look good for a page of samples, the
	ability to mix math and text in a paragraph is also important.  This
	expression \(\sqrt{3x-1}+(1+x)^2\) is an example of an inline equation.  As
	you see, MathJax equations can be used this way as well, without unduly
	disturbing the spacing between lines.</p>

	<p>
	There is no true love falling from the sky.So if you want to get into God Luo's heart,you must take action.As we all know,if you don't try to make love,love will never come into being.There are one million ways to make the love between you and God Luo.If you find one of them, your dream about love will come true.
	</p>
	<p>
	You know, God Luo always changes his necklace.This time, God Luo gets some magical beads and there are 10 kinds of these beads.We use A to denote the first kind of the beads,B to denote the second and so on.
	</p>
	<p>
	The beads can do some transformation: You can put some beads in a special vessel and whisper a secret spell(Only God Luo knows it),then these beads will become one new bead(Remember,before whispering the spell there are at least two beads ).
	</p>
	<p>
	God Luo gives the spell book to you, and this book is about something like this:"BC -&gt; D".It indecates a B-Bead and a C-Bead can become a D-Bead(Only if you have the special vessel and know the spell).
	</p>
	<p>
	After reading the spell book, you found an important fact: The right part can never be the same in any two spells(that is to say,every right part is distinct).
	</p>
	<p>
	God Luo wants to make a necklace whose components are known(At least one bead). You think it's a chance to make love,so you plan to tell God Luo the maximum of necklace can be made from the beads which he has. Maybe the right answer to that question is one of the way to make love, so it's worth a try,isn't it?
	</p>
	<p>
	CODE RIGHT NOW! FOR GOD LUO!
	</p>
</div>

<!-- Input -->
<div class="span12">
	<h2>Input</h2>
</div>
<div class="span12">
	<p>
	There is an integer T(T&lt;=100) in the first line, indecating the number of test cases.
	</p>
	<p>
	The first line of each test case contains 10 integers(no more than 50)indicating the number of each kind of beads which God Luo has.
	</p>
	<p>
	The second line contains 10 integers(no more than 50) indicating the need of each kind of beads to compose the necklace.
	</p>
	<p>
	The third line contains an interger n(0&lt;=n&lt;=10) indicating there are n spell in total.
	</p>
	<p>
	Then n lines follow,and there are two strings in each line.The first string is the left part of the spell, and the second is the right part.
	</p>
	<p>
	</p>
	<p>
	Notice:
	</p>
	<p>
	1.The length of second string is always 1.
	</p>
	<p>
	2.The length of first string is L which satisfies that 2&lt;=L&lt;=10.
	</p>
	<p>
	3.The right part of each line is distinct while some left parts can be the same.
	</p>
</div>

<!-- Output -->
<div class="span12">
	<h2>Output</h2>
</div>
<div class="span12">
	<p>
	For each test case, output the maximum number of the necklaces can be made from the initial beads.
	</p>
</div>

<!-- Sample -->
<div class="span12">
	<h2>Sample input and output</h2>
</div>
<div class="span12">
	<table class="table table-sample table-bordered table-striped">
		<thead>
			<tr>
				<th>Sample Input</th>
				<th>Sample Output</th>
			</tr>
		</thead>
		<tbody class="font-code">
			<tr>
				<td>
					<p>
					2<br />
					2 2 0 0 0 0 0 0 0 0<br />
					1 1 0 0 0 0 0 0 0 0<br />
					0<br />
					2 2 0 0 0 0 0 0 0 0<br />
					0 0 1 0 0 0 0 0 0 0<br />
					3<br />
					AB C<br />
					AAA A<br />
					AAB B<br />
					</p>
				</td>
				<td>
					<p>
					2<br />
					2<br />
					</p>
				</td>
			</tr>
		</tbody>
	</table>
</div>

<!-- Hint -->
<div class="span12">
	<h2>Hint</h2>
</div>
<div class="span12">
	<p>
	沈老师太厉害了
	</p>
</div>

<!-- Source -->
<div class="span12">
	<h2>Source</h2>
</div>
<div class="span12">
	<p>
	罗神粉丝俱乐部
	</p>
</div>

	</div>
</div>


</div>
		</div>

		<!-- Footer -->
		<div id="footer">
			<div class="container">
				<div class="row">
					<div class="span3 pull-left">
						<a id="logo-banner" href="./index.html"></a>
					</div>
					<div class="span9">
						<p class="muted credit">
						UESTC Online Judge
						</p>
						<p class="muted credit">
						Gnomovision version 69, Copyright (C) 2012 lyhypacm, mzry1992
						<br/>
						Gnomovision comes with ABSOLUTELY NO WARRANTY
						<br/>
						This is free software, and you are welcome to redistribute it under <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt">certain conditions</a>
						</p>
					</div>
				</div>
			</div>
		</div>	

	</body>
</html>


